<template>
  <view class="mt1em">
    <view class="bx" @click="clk">{{ data }}</view>
  </view>
</template>
<script lang="ts">
  import { next } from "@/util";
  import { defineComponent } from "vue";

  export default defineComponent({
    name: "jmp",
    data() {
      return {
        data: "正在跳转,请稍后",
      };
    },
    async onLoad(p: any) {
      while (!api.mid) {
        await next();
      }
      let url = "/pages/index";
      if (api.mid === "0") {
        const t = typeof p;
        this.data = `${t}: ${t == "string" ? p : JSON.stringify((p || ""))}`;
        return;
      }
      if (p) {
        if (typeof p.q == "string") {
          const t = decodeURIComponent(p.q), i = t.indexOf("path=") + 5;
          if (i >= 5) {
            url = t.substring(i);
          }
        } else if (typeof p.path == "string") {
          url = decodeURIComponent(p.path);
        }
      }
      uni.reLaunch({ url });
    },
    methods: {
      clk() {
        uni.setClipboardData({ data: this.data });
      }
    },
  });
</script>